<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title>Cargar fotos</title>
	<script type="text/javascript" src="funciones.js"></script>
	<link href="../default.css" rel="stylesheet" type="text/css" />

</head>

<body>

<?php
$eid=$_GET['eid'];
$upDir="imagenes/" . $eid . "_" . $_FILES["foto"]["name"];
$bdDir="imagenes/" . $eid . "_" . $_FILES["foto"]["name"];

if($_FILES["foto"]["error"] > 0)
{
	echo "Error al cargar la foto";
}
else
{
	if ((($_FILES["foto"]["type"] == "image/gif") || ($_FILES["foto"]["type"] == "image/jpeg") || ($_FILES["foto"]["type"] == "image/pjpeg")) && ($_FILES["foto"]["size"] < 5000000))
	{
		if(move_uploaded_file($_FILES["foto"]["tmp_name"], $upDir))
		{
			$connection=mysql_connect("localhost","root","root",false,196608);
			mysql_select_db("piaimu",$connection);
				
			if(mysql_query("INSERT INTO foto(id_excursion, tipo_foto, act_foto, path_foto_hd, path_foto_ld) VALUES('$eid','0', '1', '$bdDir', '$bdDir');",$connection))
				echo "Foto cargada exitosamente";
		}
		else
			echo "Error al cargar la foto";
	}
}

?>



</body>
</html>
